package Service;

import Dao.FindBookDao;
import Dao.InsertBorrowBookDao;
import Dao.UpdateNumsBook;
import Table.Book;

public class BorrowService {
    public static Boolean Borrow(int book_id, int user_id) {
        Book book = FindBookDao.Find(book_id);
        int nums = book.getNums();
        if (nums > 1) {
            UpdateNumsBook.Update(book_id, nums);
        } else {
            return false;
        }
        InsertBorrowBookDao.Insert(book_id, user_id);
        return true;
    }
}
